﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DataModel;

namespace P_PersonalDetails.Service.ContactNumbers
{
    public partial class ContactDetail
    {
        public string ContactValueB 
        {
            get { return this.ContactValue; }
            set
            {
                if (value != "" && !new System.Text.RegularExpressions.Regex(Regex).IsMatch(value))
                    throw new Exception(String.Format("{0} is not in the correct format for {1}", value, Name));
                if (value.Length > MaxLength)
                    throw new Exception(String.Format("{0} is {1} characters long and has a maximum length of {2}", Name, value.Length, MaxLength));
                this.ContactValue = value;
                //this.RaisePropertyChanged("ContactValueB");
                SRV.UpdateContactDetailAsync(this.MemberID, this.TypeID, value);
            }
        }
        public bool ContactOptOutB 
        {
            get 
            {
                if (this.OptOut.HasValue)
                    return this.OptOut.Value;
                else
                    return default(bool);
            } 
            set
            {
                this.OptOut = value;
                //this.RaisePropertyChanged("ContactOptOutB");
                SRV.UpdateContactOptOutAsync(this.MemberID, this.TypeID, value);
            }
        }

        ContactNumbersServiceClient SRV = ServiceConfig.NewContactNumbersClient();
    }
}
